package com.hspedu.wrapper;

/**
 * @Author Stringzhua
 * @Date 2024/3/8 17:16
 * description:
 */
public class WrapperExercise02 {
    public static void main(String[] args) {
        /*
        * 1.如果i在IntegerCache.low(-128)~IntegerCache.high(127)
        * 就直接从数组返回
        * 2.如果不在-128~127,就直接new Integer(i)
         public static Integer valueOf(int i) {
        if (i >= IntegerCache.low && i <= IntegerCache.high)
            return IntegerCache.cache[i + (-IntegerCache.low)];
        return new Integer(i);
    }
        * */
        Integer i = new Integer(1);
        Integer j = new Integer(1);
        System.out.println(i == j);//false

        Integer m = 1;//底层是Integer.valueof(1)
        Integer n = 1;//底层是Integer.valueof(1)
        System.out.println(m == n);


        ///所以，这里主要是看范围 -128 ~ 127 就是直接返回
        //否则，就 new Integer(xx);
        Integer x = 128;
        Integer y = 128;
        System.out.println(x == y);
    }
}
